package com.itheima.homework.one;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

public class Service {
    public static void main(String[] args) throws Exception {

        ServerSocket s1 = new ServerSocket(10086);

        Socket socket = s1.accept();

        InputStream inputStream = socket.getInputStream();
        BufferedInputStream b1 = new BufferedInputStream(inputStream);

        byte[] b = new byte[1024];int len = b1.read(b);

        String s = new String(b, 0, len);

        File file = new File("day15\\upload\\" + s);
        file.createNewFile();


        BufferedOutputStream b2 = new BufferedOutputStream(new FileOutputStream(file));

        while (((len = b1.read(b)) != -1)) {
            b2.write(b,0,len);

        }

        b2.flush();

        socket.close();
        s1.close();
    }


}
